{% extends "layouts/static-default.html" %}
{% block title %} {{ organisation_name }} Login {% endblock title %}

{% block stylesheets %}

    <link rel="stylesheet" href="/static/assets/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/assets/css/atlantis.css">
    <link rel="stylesheet" href="/static/assets/css/login/login.css">

{% endblock stylesheets %}

{% block content %}
    <body class="login">
    <div class="login__wrapper row">
        <div class="login__left_part col-xs-12 col-md-8">
            <div class="login__logo">
                <img src="/static/assets/img/logo-white.png">
            </div>
            <h3 class="text-white">{{ organisation_name }}</h3>
            <span class="text-white text-center mt-4">{{ login_banner|replace('\n', '<br>')|safe }}</span>
        </div>
        <div class="login__right_part col-xs-12 col-md-4">
            <h3 class="login__form_title">Sign In</h3>

            <form method="post" action="" class="login__form">
                {{ form.hidden_tag() }}
                <div class="login__form">
                    <div class="login__form_field_container">
                        <label for="username"><b>Username</b></label>
                        <input id="username" name="username" type="text" class="form-control" required="">
                    </div>
                    <div class="login__form_field_container">
                        <label for="password"><b>Password</b></label>
                        <div class="login__form_input">
                            <input id="password" name="password" type="password" class="form-control" required="">
                            <div class="login__show_password" id="togglePassword">
                                <i class="icon-eye"></i>
                            </div>
                        </div>
                    </div>
                    {% if msg %}
                        <div class="alert alert-danger"> <b>Error:</b> {{ msg }} </div>
                    {% endif %}
                    <div class="login__form_field_container">
                        <button type="submit" class="btn btn-primary login__submit_button">Sign In</button>
                        {% if auth_type == 'oidc' %}
                        <a href="/oidc-login" class="btn float-right btn-light login__submit_button">Use SSO</a>
                        {% endif %}
                    </div>
                </div>
            </form>

            <div class="login__contact_container">
                {% if ptfm_contact %}
                    <span>Don't have an account yet ?</span><br/>
                    {{ ptfm_contact }}
                {% endif %}
            </div>
        </div>
    </div>

    <script>
        const togglePassword = document.querySelector('#togglePassword');
        const password = document.querySelector('#password');

        togglePassword.addEventListener('click', function (e) {
            // toggle the type attribute
            const type = password.getAttribute('type') === 'password' ? 'text' : 'password';
            password.setAttribute('type', type);
            // toggle the eye / eye slash icon
            this.classList.toggle('login__show_password--disabled');
        });
    </script>
    </body>

{% endblock content %}